package com.plian.system.dao.sys.fun;

import com.plian.Tools.pagedata.PageData;
import com.plian.system.dao.DaoSupport;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Component
public class FunDao {
    @Resource(name = "daoSupport")
    private DaoSupport dao;
    /**
     * 根据用户和单位id查询权限
     * @param pd
     * @return
     * @throws Exception
     */
    public int Permissions(PageData pd) throws Exception {
        return (int) dao.findForObject("SysFunMapper.Permissions",pd);
    }
    /**
     * 保存
     * @param pd
     * @throws Exception
     */
    public void save(PageData pd) throws Exception {
        dao.save("SysFunMapper.save",pd);
    }
    /**
     * 修改
     * @param pd
     * @throws Exception
     */
    public void  edit(PageData pd) throws Exception {
        dao.update("SysFunMapper.edit",pd);
    }

    /**
     * 根据id查询
     * @param id
     * @return
     * @throws Exception
     */
    public PageData findbyid(String id) throws Exception {
        return (PageData) dao.findForObject("SysFunMapper.findbyid",id);
    }
    /**
     * 根据id组删除数据
     * @param ids
     * @throws Exception
     */
    public void del_ids(List<String> ids) throws Exception {
        dao.delete("SysFunMapper.del_ids",ids);
    }
    //查询列表
    public List<PageData> list(PageData pd) throws Exception {
        return (List<PageData>) dao.findForList("SysFunMapper.list",pd);
    }
    /**
     * 批量调整
     * @param pd
     * @throws Exception
     */
    public void adjustment(PageData pd) throws Exception {
        dao.update("SysFunMapper.adjustment",pd);
    }

    public List<PageData> getByFormType()  {
        List<PageData> pageData = new ArrayList<>();
        try {
            pageData =  (List<PageData>) dao.findForList("SysFunMapper.getByFormType",null);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return pageData;
    }

}
